// Author: combacsa@kaist.ac.kr
// http://www.jungol.co.kr/prog/Hanal/hanalView.php?qs_code=1005

//#define COMPILE
#ifdef COMPILE

#include <fstream>
using namespace std;

int n;
int maxnum = 0;
int ans;
int bigsosu;
int sn = 0;
int sosu[5000];
int data[5000];

void input() {
	ifstream in("input.txt");
	in >> n;
	for (int i = 0; i < n; i++) {
		in >> data[i];
		if (maxnum < data[i]) maxnum = data[i];
	}

	in.close();
}


int largest(int x) {
	int large = 1;
	for (int i = 0; i < sn; i++) {
		if (x % sosu[i] == 0)
			large = sosu[i];
	}
	return large;
}

void get_sosu() {
	for (int i = 2; i <= maxnum; i++) {
		bool issosu = true;
		for (int j = 0; j < sn; j++) {
			if (i % sosu[j] == 0) {
				issosu = false;
				break;
			} else if (sosu[j] * sosu[j] > i) break;
		}
		if (issosu) {
			sosu[sn++] = i;
		}
	}
}

void solve() {
	get_sosu();
	ans = data[0];
	int bigsosu = largest(data[0]);
	for (int i = 1; i < n; i++) {
		if (largest(data[i]) > bigsosu) {
			ans = data[i];
			bigsosu = largest(data[i]);
		}
	}
}

void output() {
	ofstream out("output.txt");
	out << ans << endl;
	out.close();
}

int main() {
	input();
	solve();
	output();

	return 0;
}
#endif
